package exo5;


public class Ouvrage {
	protected static final String AL = "\n";
	private int id;
	private String titre;
	private String media;
	private int anneeEdition;
	private boolean disponibilite;
	private boolean etatReservation;
	private Abonne abonne;
	
	public String getTitre(){
		return this.titre;
	} 
	public int getAnneeEdition(){
		return this.anneeEdition;
	}
	public boolean isDisponibilite(){
		return this.disponibilite;
	}
	public boolean isEtatReservation(){
		return this.etatReservation;
	}
	public String getMedia(){
		return this.media;
	}
	
	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}
	/**
	 * @param id the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}
	
	public Ouvrage(int id, String t, String m, int ae, boolean d, boolean er, Abonne a){
		this.setId(id);
		titre = t;
		media = m;
		setDisponibilite(false);
		etatReservation = true;
		abonne = a;
		
	}
	
	
	@Override
	public String toString(){
		StringBuilder affichage = new StringBuilder();
		affichage.append("     Titre : ").append(titre).append(AL)
			.append("     Media :").append(media).append(AL)
			.append("     Disponibilite :").append(isDisponibilite()).append(AL)
			.append("     Etat reservation :").append(etatReservation).append(AL)
			.append("     Emprunteur :").append(abonne).append(AL);
		return affichage.toString();
	}
	
	/**
	 * @param disponibilite the disponibilite to set
	 */
	public void setDisponibilite(boolean disponibilite) {
		this.disponibilite = disponibilite;
	}
	
	public void setEtatReservation(boolean etatReservation){
		this.etatReservation = etatReservation;
	}
	/**
	 * @return the id
	 */
	
	@Override
	public int hashCode(){
		return this.getMedia().hashCode();
	}
	@Override
	public boolean equals(Object obj){
		Ouvrage ouv;
		if(obj == null || obj.getClass() != this.getClass()){
			return false;
		}else{
			ouv = (Ouvrage) obj;
			if(ouv.getMedia().equals(getMedia())){
				return true;
			}else{
				return false;
			}
		}
	}
	
	
}
